﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dawn_of_Man
{
    [Serializable()]
    public class Homosapien
    {
        //Name of the person
        public string name { get; set; }
        //Current age 
        public double age { get; set; }
        //Sex, true if man, false if woman
        public bool sex { get; set; }
        //Hunger in %
        public int hunger { get; set; }
        //Health in % (meat to wheat ratio)
        public int health { get; set; }
        //What is he currently doing?
        public Building building { get; set; }
        public Area area { get; set; }
        public Assignment assignment { get; set; }
        //What has he eaten?
        public List<Ressource> stumach { get; set; }
        //What is he carrying?
        public List<Ressource> carrying { get; set; }

        public override string ToString()
        {
            return name;
        }

        public String GetSex()
        {
            if (sex)
                return "man";
            else
                return "woman";
        }

        public void setBuilding(Building building)
        {
            this.building = building;
            this.area = null;
        }

        public void setArea(Area area)
        {
            this.area = area;
            this.building = null;

        }

        public String GetHealth()
        {
            if (health == 0)
                return "dead";
            else if (health < 5)
                return "near death";
            else if (health < 10)
                return "ill";
            else if (health < 20)
                return "very bad";
            else if (health < 30)
                return "bad";
            else if (health < 40)
                return "worsening";
            else if (health < 50)
                return "normal";
            else if (health < 60)
                return "bettering";
            else if (health < 70)
                return "good";
            else if (health < 80)
                return "very good";
            else if (health < 90)
                return "excellent";
            else if (health <= 100)
                return "perfect";
            else
                return "error";
        }
        public String GetHunger()
        {
            if (hunger == 0)
                return "starving";
            else if (hunger < 5)
                return "close to starving";
            else if (hunger < 10)
                return "extremely hungry";
            else if (hunger < 20)
                return "very hungry";
            else if (hunger < 30)
                return "tummy ache";
            else if (hunger < 40)
                return "hungry";
            else if (hunger < 50)
                return "normal";
            else if (hunger < 60)
                return "content";
            else if (hunger < 70)
                return "almost full";
            else if (hunger < 80)
                return "full";
            else if (hunger < 90)
                return "sated";
            else if (hunger <= 100)
                return "fully sated";
            else
                return "error";
        }

        public void removeActivity()
        {
            if (building != null && area == null)
            {
                building.removeWorker(this);
                building = null;
                assignment = null;
            }
            else if (area != null && building == null)
            {
                area.removeWorker(this);
                area.removeHunter(this);
                area = null;
                assignment = null;
            }
            else
            {
                //Shouldnt happen
            }
        }

    }


}
